package com.yy.db;

import com.yy.pojo.User;

public class UserDBUtil extends DBUtil{

    public User login(String name,String pwd){

        User user =null;
        try {
            getConn();
            String sql="select * from `user` where name=? and pwd=?";
            ps = conn.prepareStatement(sql);
            ps.setObject(1,name);
            ps.setObject(2,pwd);
            rs = ps.executeQuery();
            if(rs.next()){
                user =new User(rs.getInt(1),
                        rs.getString(2),
                        rs.getString(3),
                        rs.getString(4));
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            closeConn();
        }
        return user;
    }
}
